#pragma once

#include <iostream>
#include <vector>

typedef void (*task_t)();

void PrintLog()
{
    std::cout << "这是一个打印Log任务..." << std::endl;
}

void download()
{
    std::cout << "这是一个下载任务..." << std::endl;
}

void submit()
{
    std::cout << "这是一个上传任务..." << std::endl;
}

class TaskManager
{
public:
    TaskManager()
    {
        srand(time(nullptr));
    }
    void Register(task_t t)
    {
        tasks.push_back(t);
    }
    int Code()
    {
        return rand() % tasks.size();
    }
    void Excute(int code)
    {
        if (code >= 0 && code < tasks.size())
        {
            tasks[code]();
        }
    }
    ~TaskManager() {}

private:
    std::vector<task_t> tasks;
};